﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ExcelExportLib
{

    /// <summary>Position of cell in R1C1 notation because they are significantly easier to parse and generate than A1-style formulas </summary>
    public class ExcelCellPosition
    {
        /// <summary>table name </summary>
        public readonly string tableName;
        /// <summary>row number </summary>
        public readonly int row;
        /// <summary>column number </summary>
        public readonly int column;

        /// <summary>Constructor for serialisation only </summary>
        public ExcelCellPosition() {}

        /// <summary>Constructor </summary>
        public ExcelCellPosition(int row, int column)
        {
            this.row = row;
            this.column = column;
            this.tableName = null;
        }

        /// <summary>Constructor </summary>
        public ExcelCellPosition(string tableName, int row, int column)
        {
            this.row = row;
            this.column = column;
            this.tableName = tableName;
        }

        public override string ToString()
        {
            if (String.IsNullOrEmpty(tableName))
                return "R" + row + "C" + column;
            else
                return "'" + tableName + "'!R" + row + "C" + column;
        }
    }
}
